# @Time    :2025/4/3 16:59
"""
类装饰器是包含 __call__() 方法的类，它接受函数作为参数，并返回新的函数
"""
from math import sqrt


class DecoratorClass:
    def __init__(self, f):
        self.f = f

    def __call__(self, x):
        x = abs(x)
        return self.f(x)

@DecoratorClass
def func(x):
    return sqrt(x)
print(func(-4))